<template>
	<view class="cell-page">
		<view class="pl-20 pr-20 bg-white pb-20 mb-20">
			<u-subsection 
				:list="tags"
				:current="selectTag" 
				keyName="label"
				mode="subsection"
				:bold="false"
				activeColor="#e54d42"
				@change="sectionChange"
			/>
		</view>
		<view class="my-list padding-0">
			<u-list :height="swiperHeight" v-if="dataList.length > 0" @scrolltolower="scrolltolower">
				<u-list-item v-for="(item, index) in dataList" :key="item.id">
					<view class="flex align-center bg-white pl-20 pr-20" @click="$u.route('/pages/customer/details',{id: item.id})">
						<view class="shrink0"><u-avatar :src="item.avatarImage" size="46" default-url="/static/logo.png"/></view>
						<view class="flex justify-between align-center w-100 border-b pl-10 ml-14 pt-24 pb-24">
							<view class="">
								<view class="flex">
									<text>{{item.nickName}}</text>
									<u-icon v-if="item.sex!==3" size="15" :name="item.sex===1?'man':'woman'" :color="item.sex===1?'#3c9cff':'#f56c6c'" />
								</view>
								<view class="fsize-26 line-gray mt-10">{{item.gradeName}}</view>
							</view>
							<view @click.stop="phoneCall(item.mobile)">
								<uni-icons custom-prefix="iconfont" type="icon-phone" color="#81c66d" size="30"/>
							</view>
						</view>
					</view>
				</u-list-item>
			</u-list>
		</view>
		<u-empty text="内容为空" mode="data" v-if="dataList.length===0" marginTop="150" />
	</view>
</template>

<script>	
	import listHeightMixin from '@/common/computedAltitude.js'
	import { mapState } from 'vuex'
	export default {
		mixins:[listHeightMixin],
		data() {
			return {
				tags: [
					{ label: '近30天', value: 30 }, 
					{ label: '近15天', value: 15 }, 
					{ label: '近7天', value: 7 },
					{ label: '近3天', value: 3 },
					{ label: '今天', value: 0 },
				],
				loadMore: false,
				dataList:[],
				selectTag: 0,
				searchData:{
					birthdays: 30,
					page: 1,
					limit: 20
				},
			}
		},
		
		onLoad() {
			this.getPageList();
		},
		computed: {
			...mapState(['userInfo'])
		},
		methods: {
			getPageList(){
				this.searchData.clientType = this.userInfo.roleCategoryId
				this.$reqPost('GetShareholderUsersPageList', this.searchData).then(res=>{
					this.total = res.otherData.userExpand.userCount
					this.dataList = [...this.dataList, ...res.data]
					if (res.count > this.dataList.length) {
						this.searchData.page++
						this.loadMore = true
					}else {
						this.loadMore = false
					}
				})
			},
			scrolltolower(){
				if(this.loadMore){
					this.getPageList()
				}
			},
			phoneCall(num){
				uni.makePhoneCall({ phoneNumber: num })
			},
			sectionChange(index) {
				if(this.selectTag !== index){
					this.selectTag = index
					this.searchData.birthdays = this.tags[index].value
					this.dataList = []
					this.searchData.page = 1
					this.getPageList()
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.search-box {
		padding: 20rpx;
		background-color: #fff;
	}
	.u-page{
		background-color:#fff;
	
	}
	.cell{
		.title{ font-size: 32rpx;}
		.value{ font-size: 20rpx;}
		.label{ font-size: 20rpx;}
	}
	.cell_item{ background: #FFFFFF;}
	.u-cell__body{background: #FFFFFF;}
	
	.group_title {
		display: block;
		margin-left: 20rpx;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		font-size: 28rpx;
		color: #666;
		.title{
			display: inline-block;
		}
		.btn{
			float: right;
			margin-right: 20rpx;
			color:#111;
			display: inline-block;
		}
	}
	.u-cell-label{
		font-size: 24rpx;
		color: #888;
	}
</style>
